package com.recallgo.manage.web.controller;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.recallgo.manage.entity.ItemDesc;
import com.recallgo.manage.service.ItemDescService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * <p>
 * 商品描述表 前端控制器
 * </p>
 *
 * @author fendo
 * @since 2018-09-11
 */
@Controller
@RequestMapping("/rest/item/desc")
public class ItemDescController {

    @Autowired
    private ItemDescService itemDescService;

    /**
     * 根据商品id查询商品描述
     * @param itemId
     * @return
     */
    @RequestMapping(value = "{itemId}", method = RequestMethod.GET)
    public ResponseEntity<ItemDesc> queryByItemId(@PathVariable("itemId") Long itemId){
        EntityWrapper<ItemDesc> wrapper = new EntityWrapper<>();
        wrapper.where("item_id = {0}", itemId);
        ItemDesc itemDesc = itemDescService.selectOne(wrapper);
        if(null == itemDesc){
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        }
        return ResponseEntity.ok(itemDesc);
    }
}

